<div class="default-background">
    <h2 class="flex-row-space-between">{{'SECURITY_PROFILE_DASHBOARD' |translate}}</h2>
    <app-search (search)="doSearch($event)" [searchConfigs]="searchConfigs">
    </app-search>
    <div>
        <div class="table-container">
            <table mat-table [dataSource]="tableSource.dataSource">

                <ng-container matColumnDef="id">
                    <th mat-header-cell *matHeaderCellDef> {{columnList['id']|translate}} </th>
                    <td mat-cell *matCellDef="let row">
                        <app-copy-field [inputValue]="row.id"></app-copy-field>
                    </td>
                </ng-container>
                <ng-container matColumnDef="name">
                    <th mat-header-cell *matHeaderCellDef> {{columnList['name']|translate}} </th>
                    <td mat-cell *matCellDef="let row">
                        <app-copy-field [inputValue]="row.name"></app-copy-field>
                    </td>
                </ng-container>

                <ng-container matColumnDef="resourceId">
                    <th mat-header-cell *matHeaderCellDef> {{columnList['resourceId']|translate}} </th>
                    <td mat-cell *matCellDef="let row">
                        <app-editable-page-select-single [readOnly]="true" [inputValue]="getOption(row)">
                        </app-editable-page-select-single>
                    </td>
                </ng-container>
                <ng-container matColumnDef="description">
                    <th mat-header-cell *matHeaderCellDef> {{columnList['description']|translate}} </th>
                    <td mat-cell *matCellDef="let row">
                        <app-copy-field [inputValue]="row.description"
                            (newValue)="doPatch(row.id,$event,'description')">
                        </app-copy-field>
                    </td>
                </ng-container>

                <ng-container matColumnDef="path">
                    <th mat-header-cell *matHeaderCellDef> URL </th>
                    <td mat-cell *matCellDef="let row">
                        <app-copy-field [inputValue]="row.path" (newValue)="doPatch(row.id,$event,'path')">
                        </app-copy-field>
                    </td>
                </ng-container>


                <ng-container matColumnDef="method">
                    <th mat-header-cell *matHeaderCellDef> {{columnList['method']|translate}} </th>
                    <td mat-cell *matCellDef="let row">
                        <ng-container *ngIf="!row.websocket">
                            <app-editable-select-single [inputValue]="getHttpOption(row.method,httpMethodList)"
                                [list]="httpMethodList" (newValue)="doPatch(row.id,$event,'method')">
                            </app-editable-select-single>
                        </ng-container>
                        <ng-container *ngIf="row.websocket">
                            <span style="margin-left: 16px;">N/A</span>
                        </ng-container>
                    </td>
                </ng-container>

                <ng-container matColumnDef="more">
                    <th mat-header-cell *matHeaderCellDef class="table-icon">{{columnList['more']|translate}}</th>
                    <td mat-cell *matCellDef="let row" class="table-icon">
                        <mat-icon (click)="viewEndpoint(row.id)" [color]="'primary'">remove_red_eye</mat-icon>
                    </td>
                </ng-container>
                <tr mat-header-row *matHeaderRowDef="tableSource.displayedColumns(); sticky: true"></tr>
                <tr mat-row *matRowDef="let row; columns: tableSource.displayedColumns();"></tr>
            </table>
        </div>

        <mat-paginator [showFirstLastButtons]="true" [length]="tableSource.totoalItemCount"
            [pageIndex]="tableSource.pageNum" [pageSize]="tableSource.pageSize"
            (page)="tableSource.loadPage($event.pageIndex)">
        </mat-paginator>
    </div>
</div>